/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package daos;

import beans.Bean;
import beans.ObraSocialBean;
import beans.PrestadoraBean;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Cristian Ketibian
 * @version 1.0
 */
public class MSSQLPrestadoraDao extends MSSQLDao implements Dao{
    
     public MSSQLPrestadoraDao() throws Exception {
        super();
    }

     @Override
    public Bean make(ResultSet result) throws Exception {
        PrestadoraBean p= new PrestadoraBean();
        System.out.println(result.getString("nombre_prestadora"));
        p.setId_prestadora(result.getInt("id_prestadora"));
        p.setNombre(result.getString("nombre_prestadora")); 
        p.setAccesoWS(result.getString("acceso_ws"));          
        p.setCalle(result.getString("calle"));
        p.setNumero(result.getString("numero"));
        p.setPiso(result.getString("piso"));
        p.setDepto(result.getString("depto"));        
        p.setBarrio(result.getString("nombre_barrio"));        
        p.setCiudad(result.getString("nombre_ciudad"));
        p.setProvincia(result.getString("nombre_provincia"));        
        p.setPais(result.getString("pais"));
        p.setEmail(result.getString("email_prestadora"));
        p.setPaginaWeb(result.getString("pagina_web_prestadora"));
        p.setTelefono(result.getString("telefono_prestadora"));
        p.setHorario(result.getString("horario_atencion"));
        p.setNombre_contacto(result.getString("nombre_contacto"));
        p.setHorario_contacto(result.getString("horario_contacto"));
        p.setEmail_contacto(result.getString("email_contacto"));
        return p;
    }


    @Override
    public long insert(Bean bean) throws Exception {
      throw new UnsupportedOperationException("Not supported yet.");   
    }

     @Override
    public void update(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void delete(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

     @Override
    public List<Bean> select(Bean bean) throws Exception {
         List<Bean> resultados = new ArrayList<Bean>();          
         try{
             ResultSet result;           
             this.setStatement("get_prestadoras(?)"); 
             this.getStatement().setString(1, ((ObraSocialBean) bean).getNombre());        
             result = this.getStatement().executeQuery();       
             while(result.next()) {
                 resultados.add(this.make(result));
             }  
         } catch (SQLException ex) {            
             return null;
         } catch (Exception ex2) { throw ex2; }  
         finally { this.destroy(); }
         return resultados;  
    }

     @Override
    public boolean valid(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Bean get(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }    

     @Override
    public long getSize(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

   
  

}
